#!/usr/bin/python
# -*- coding: utf-8 -*-
"""
Mikan Preference Package

Mikan Python Web Framework
"""

__author__ = "K.Sonohara"
__status__ = "develop"
__version__ = "0.0.0_33"
__date__    = "2013/12/08"
__license__ = 'LGPL'

# ------------------------------------------------------------
## Import Section
# ------------------------------------------------------------
# Python

# Mikan
from mikan.preference import MikanINIPreference

# ------------------------------------------------------------
## Variable Section
# ------------------------------------------------------------

# ------------------------------------------------------------
## Function Section
# ------------------------------------------------------------

# ------------------------------------------------------------
## Class Section
# ------------------------------------------------------------

## Mikan Preference Abstract Class
#
class MikanKVSPreference(MikanINIPreference):

	def get_user_name(self):
		return self.request.username

	def get_group_name(self):
		return self.request.groupname

	def set_user_value(self, name, value):
		self.request.kvs.set("user", self.get_user_name(), name, value)

	def set_group_value(self, name, value):
		self.request.kvs.set("group", self.get_group_name(), name, value)

	def set_site_value(self, name, value):
		self.request.kvs.set("site", "default", name, value)

	def get_user_value(self, name):
		try:
			return self.request.kvs.get("user", self.get_user_name(), name)
		except:
			return None

	def get_group_value(self, name):
		try:
			return self.request.kvs.get("group", self.get_group_name(), name)
		except:
			return None

	def get_site_value(self, name):
		try:
			return self.request.kvs.get("site", "default", name)
		except:
			return None
	# ----------------------------------------------------
	## constructor
	#  @param request request
	def __init__(self, request):
		super(MikanKVSPreference, self).__init__(request)

# ------------------------------------------------------------
## Main Section
# ------------------------------------------------------------
if __name__ == '__main__':
	pass

# ------------------------------------------------------------
